<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 全局变量
        var s = [23, 65, 98, 5];

        // 数组原型上新增一个公共方法myMap
        Array.prototype.myMap = function (callback) {
            var newArray = [];
            let arr = this;
            let that = arguments[1];
            for (let i = 0; i < arr.length; i++) {
                newArray.push(callback.call(that, arr[i], arr));
            }
            return newArray;
        };

        var new_s = s.myMap(function (item) {
            return item * 2;
        });
        console.log(new_s);
    </script>
</body>

</html>